<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>用户管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <script type="text/javascript" src="js/cookie.js"></script>
    <script type="text/javascript" src="js/address.js"></script>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
</head>
<script>
    function URull(urull){
        switch(urull){
            case 0:return "待定职位";break;
            case 1:return "经理";break;
            case 2:return "揽收员";break;
            case 3:return "派送员";break;
            case 4:return "转运员";break;
            case 5:return "打包拆包人员";break;
            default:break;
        }
    }
    $(function(){
        $("#submit").click(function () {
            var str= address + "user/list/"+$("#select").val()+"/"+$("#selectway").val()+"/"+$("#input").val();
            $.ajax({
                url:str,
                type:"GET",
                dataType:'JSON',
                contentType : "application/json; charset=utf-8",
                success:function(data){
                    if(data.code.code === 0) {
                        var tableData;
                        var user = data.userList;
                        $("#numspan").text("显示数据：" + (user.length).toString() + "条");
                        for (var i = 0; i < user.length; i++) {
                            var str = "<td class='td-manage'>" +
                                '<a title="编辑"  href="javascript:;"  onclick="x_admin_show( \'编辑\',\'employee-edit.html? Data=' + user[i].uId + '\',600,400)">' +
                                "<i class=\"layui-icon\">&#xe642;</i>" +
                                "</a>" +
                                '<a title="删除" href="javascript:;" onclick="employee_del(this,' + user[i].uId + ')">' +
                                "<i class='layui-icon'>&#xe640;</i> " +
                                "</a> " +
                                "</td>";

                            tableData += "<tr> " +
                                "<td>" + user[i].uId + "</td> " +
                                "<td>" + user[i].name + "</td>" +
                                "<td>" + URull(user[i].uRull)+ "</td>" +
                                "<td>" + user[i].telCode + " </td>" +
                                "<td>" + user[i].status + "</td>" +
                                "<td>" + user[i].dptId + "</td>" +
                                "<td>" + user[i].receivePackageId + "</td> " +
                                "<td>" + user[i].delivePackageId + "</td> " +
                                "<td>" + user[i].transPackageId + "</td> "
                                + str +
                                "</tr>";
                        }
                        $("#firsttbody").html(tableData);
                    }else{
                        alert(data.code.message);
                    }
                },
                error:function(){
                    alert("error");
                }
            });
        });
    });
</script>

<body>
   <div class="x-nav">
       <span class="layui-breadcrumb">
           <a href="">员工列表</a>
       </span>
       <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
           <i class="layui-icon" style="line-height:30px">刷新</i></a>
       </div>
   <div class="x-body">
       <div class="layui-row">
           <form class="layui-form layui-col-md12 x-so" method="#">
               <div class="layui-input-inline" style="margin-left: 380px">
                   <select id="select">
                       <option value="UID">用户ID</option>
                       <option value="Name">姓名</option>
                       <option value="URull">职位</option>
                       <option value="TelCode">电话号码</option>
                       <option value="Status">状态</option>
                       <option value="DptID">部门编号</option>
                       <option value="ReceivePackageID">揽收包裹编号</option>
                       <option value="DelivePackageID">派送包裹编号</option>
                       <option value="TransPackageID">传送包裹编号</option>
                   </select>
               </div>
               <div class="layui-input-inline">
                   <select id="selectway">
                       <option value="eq">等值查找</option>
                       <option value="like">模糊查找</option>
                   </select>
               </div>
               <input id="input" class="layui-input" type="text" name="customername" placeholder="请输入..." autocomplete="off" value="">
               <button class="layui-btn" id="submit" type="button"><i class="layui-icon">&#xe615;</i></button>
           </form>
       </div>
       <xblock>
           <button class="layui-btn" onclick="x_admin_show('添加用户','./employee-add.html',600,400)"><i class="layui-icon"></i>添加</button>
           <span class="x-right" id="numspan" style="line-height:40px">显示数据：0条</span>
       </xblock>
       <table class="layui-table x-admin">
        <thead>
        <tr>
            <th>UID</th>
            <th>姓名</th>
            <th>职位</th>
            <th>电话号码</th>
            <th>状态</th>
            <th>部门编号</th>
            <th>揽收包裹编号</th>
            <th>派送包裹编号</th>
            <th>传送包裹编号</th>
            <th>编辑</th>
        </tr>
        </thead>

        <tbody id="firsttbody"></tbody>

        </table>

        <div class="page">
            <div>
                <a class="prev" href="">&lt;&lt;</a>
                <a class="num"  href="">1</a>
                <a class="next" href="">&gt;&gt;</a>
            </div>
        </div>

   </div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#start'
        });

        laydate.render({
            elem: '#end'
        });
    });

    /*用户-删除*/
    function employee_del(obj, uId){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            var str= address + "user/deleteUserInfo/" + uId;
            $.ajax({
                url:str,
                type:"GET",
                dataType:'JSON',
                contentType : "application/json; charset=utf-8",
                success:function(data){
                    layer.msg('已删除!',{icon:1,time:1000});
                },
                error:function(){
                    alert("error");
                }
            });
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }
</script>
</body>
</html>